<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link href="/static/css/bootstrap.css" rel="stylesheet">
    <script type="text/javascript" src="/static/js/jquery-3.2.1.js"></script>
</head>
<body>
<center>
    <h3>列表页面</h3>
    <form action="/main/list" method="post">
        场馆:<select name="sid">
            <option value="0">-请选择-</option>
        </select>
        项目类型:<select name="tid">
            <option value="0">-请选择-</option>
        </select>
        场地:<select name="aid">
            <option value="0">-请选择-</option>
        </select>
        <button>查询</button>
    </form>
    <a href="/main/toAdd">添加</a>
    <a href="/main/toCountNum">统计报表</a>
    <table class="table">
        <tr>
            <td>场馆</td>
            <td>项目类型</td>
            <td>场地</td>
            <td>开始时间</td>
            <td>结束时间</td>
            <td>价格</td>
            <td>最近更新时间</td>
            <td>最近更新人</td>
        </tr>
        <c:forEach items="${pg.list}" var="main">
            <tr>
                <td>${main.sname}</td>
                <td>${main.tname}</td>
                <td>${main.aname}</td>
                <td>${main.startTime}</td>
                <td>${main.endTime}</td>
                <td>${main.price}</td>
                <td><fmt:formatDate value="${main.updated}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate> </td>
                <td>${main.username}</td>
            </tr>
        </c:forEach>
    </table>
    <jsp:include page="/static/common/pages.jsp"></jsp:include>
</center>
</body>
<script>
    $(function () {
        $.get(
            "/main/getStadium",
            function (list) {
                for (var i in list) {
                    $("[name='sid']").append("<option value='"+list[i].sid+"'>"+list[i].sname+"</option>")
                }
                $("[name='sid']").val('${main.sid}');
            }
        )
        $.get(
            "/main/getType",
            function (list) {
                for (var i in list) {
                    $("[name='tid']").append("<option value='"+list[i].tid+"'>"+list[i].tname+"</option>")
                }
                $("[name='tid']").val('${main.tid}');
            }
        )
        $.get(
            "/main/getArea",
            function (list) {
                for (var i in list) {
                    $("[name='aid']").append("<option value='"+list[i].aid+"'>"+list[i].aname+"</option>")
                }
                $("[name='aid']").val('${main.aid}');
            }
        )
    })
</script>
</html>